package com.eastfair.venuebooking.enumeration;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * 商机类型 enum.
 *
 * @author dqq
 * @date 2023 /2/21
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum BusinessOpportunityTypeEnum implements BaseEnum {

    /**
     * EXHIBITION="展会"
     */
    EXHIBITION("展会"),
    /**
     * MEETING="会议"
     */
    MEETING("会议"),
    /**
     * FORUM="论坛"
     */
    FORUM("论坛"),
    /**
     * OTHER="其他"
     */
    OTHER("其他"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static BusinessOpportunityTypeEnum match(String val, BusinessOpportunityTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static BusinessOpportunityTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(BusinessOpportunityTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "EXHIBITION,MEETING,FORUM,OTHER", example = "EXHIBITION")
    public String getCode() {
        return this.name();
    }
}